home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / datamgr / tablfrm2.frm < prev    next >
Text File  |  1995-10-23  |  8KB  |  259 lines

  1. VERSION 2.00
  2. Begin Form TableForm 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "Table Form"
  5.    ClientHeight    =   6075
  6.    ClientLeft      =   1230
  7.    ClientTop       =   1425
  8.    ClientWidth     =   8475
  9.    ClipControls    =   0   'False
  10.    Height          =   6480
  11.    Icon            =   TABLFRM2.FRX:0000
  12.    Left            =   1170
  13.    LinkTopic       =   "Form1"
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   6075
  16.    ScaleWidth      =   8475
  17.    Top             =   1080
  18.    Width           =   8595
  19.    Begin CommandButton Command5 
  20.       Caption         =   "Dele&te"
  21.       Height          =   375
  22.       Left            =   1800
  23.       TabIndex        =   7
  24.       Top             =   3840
  25.       Width           =   1215
  26.    End
  27.    Begin CommandButton Command4 
  28.       Caption         =   "A&dd"
  29.       Height          =   375
  30.       Left            =   600
  31.       TabIndex        =   6
  32.       Top             =   3840
  33.       Width           =   1215
  34.    End
  35.    Begin CommandButton Command3 
  36.       Caption         =   "De&lete"
  37.       Height          =   375
  38.       Left            =   1800
  39.       TabIndex        =   3
  40.       Top             =   720
  41.       Visible         =   0   'False
  42.       Width           =   1215
  43.    End
  44.    Begin CommandButton Command1 
  45.       Caption         =   "&Add"
  46.       Height          =   375
  47.       Left            =   600
  48.       TabIndex        =   2
  49.       Top             =   720
  50.       Width           =   1215
  51.    End
  52.    Begin Grid Grid2 
  53.       Cols            =   5
  54.       FontBold        =   0   'False
  55.       FontItalic      =   0   'False
  56.       FontName        =   "MS Sans Serif"
  57.       FontSize        =   8.25
  58.       FontStrikethru  =   0   'False
  59.       FontUnderline   =   0   'False
  60.       Height          =   1335
  61.       HighLight       =   0   'False
  62.       Left            =   600
  63.       TabIndex        =   5
  64.       Top             =   4200
  65.       Width           =   7335
  66.    End
  67.    Begin Grid Grid1 
  68.       Cols            =   4
  69.       FontBold        =   0   'False
  70.       FontItalic      =   0   'False
  71.       FontName        =   "MS Sans Serif"
  72.       FontSize        =   8.25
  73.       FontStrikethru  =   0   'False
  74.       FontUnderline   =   0   'False
  75.       Height          =   1935
  76.       HighLight       =   0   'False
  77.       Left            =   600
  78.       Rows            =   4
  79.       TabIndex        =   1
  80.       Top             =   1080
  81.       Width           =   7335
  82.    End
  83.    Begin Label TableName 
  84.       BorderStyle     =   1  'Fixed Single
  85.       Height          =   255
  86.       Left            =   5760
  87.       TabIndex        =   8
  88.       Top             =   5760
  89.       Visible         =   0   'False
  90.       Width           =   1935
  91.    End
  92.    Begin Label Label1 
  93.       BackStyle       =   0  'Transparent
  94.       Caption         =   "&Indexes:"
  95.       FontBold        =   -1  'True
  96.       FontItalic      =   0   'False
  97.       FontName        =   "MS Sans Serif"
  98.       FontSize        =   12
  99.       FontStrikethru  =   0   'False
  100.       FontUnderline   =   0   'False
  101.       Height          =   375
  102.       Left            =   120
  103.       TabIndex        =   4
  104.       Top             =   3360
  105.       Width           =   1215
  106.    End
  107.    Begin Label Label3 
  108.       BackStyle       =   0  'Transparent
  109.       Caption         =   "Field&s:"
  110.       FontBold        =   -1  'True
  111.       FontItalic      =   0   'False
  112.       FontName        =   "MS Sans Serif"
  113.       FontSize        =   12
  114.       FontStrikethru  =   0   'False
  115.       FontUnderline   =   0   'False
  116.       Height          =   375
  117.       Left            =   120
  118.       TabIndex        =   0
  119.       Top             =   240
  120.       Width           =   1215
  121.    End
  122. End
  123. Option Explicit
  124.  
  125.  
  126. Sub Command1_Click ()
  127.     Dim f As New fieldForm
  128.     Dim table As String
  129.  
  130.     f.Caption = "Add Field"
  131.     f.Show 1
  132.  
  133.     If f.ExitCondition = "OK" Then
  134.  
  135.         If Me.TableName = "New Table" Then
  136.             table = Mid$(Me.Caption, 8)
  137.             If Not AddTable(table, f.FName, f.fType, f.FSize, f.cCounter) Then
  138.                 'MsgBox "Field Not Added", 64, "Data Manager"
  139.                 Unload Me
  140.                 Exit Sub
  141.             Else
  142.                 Me.TableName = table
  143.                 Me.Caption = "Table: " + table
  144.             End If
  145.         Else
  146.             If Not addField(Me.TableName, f.FName, f.fType, f.FSize, f.cCounter) Then
  147.                 MsgBox "Could Not Add Field.", 64, "Data Manager"
  148.                 Exit Sub
  149.             End If
  150.         End If
  151.  
  152.         If Not RefreshTableFields(Me, (Me.TableName)) Then
  153.             MsgBox "Error While Refreshing Table Information.  Data displayed may be incorrect.", 64, "Data Manager"
  154.         End If
  155.  
  156.     End If
  157.     Unload fieldForm
  158. End Sub
  159.  
  160. Sub Command3_Click ()
  161.     Dim x As Integer
  162.     Dim field As String
  163.  
  164.     On Error Resume Next
  165.  
  166.     grid1.Col = 1
  167.     field = grid1.Text
  168.  
  169.     If field = "" Then
  170.         MsgBox "No Field Selected:  You must select a field before it can be deleted", 64, "Data Manager"
  171.     Else
  172.         x = MsgBox("Are You Sure You Want To Delete Field:  """ + field + """?", 33, "Data Manager")
  173.         If x = 1 Then
  174.             gDatabase.TableDefs.Refresh
  175.             gDatabase.TableDefs(Me.TableName).Fields.Refresh
  176.             If Err <> 0 Then
  177.                 MsgBox "Error While Attempting To Refresh Table Info.  Database may have been altered by another source.  Displayed Information May be Incorrect:" + Chr$(13) + Error$, 64, "Data Manager"
  178.                 Exit Sub
  179.             End If
  180.  
  181.             gDatabase.TableDefs(Me.TableName).Fields.Delete field
  182.             If Err <> 0 Then
  183.                 MsgBox "Could Not Delete Field:  """ + field + Chr$(13) + Error$, 64, "Data Manager"
  184.                 Exit Sub
  185.             Else
  186.                 If Not RefreshTableFields(Me, (Me.TableName)) Then
  187.                     MsgBox "Error While Attempting To Refresh Table Info.    Displayed Information May be Incorrect:" + Chr$(13) + Error$, 64, "Data Manager"
  188.                 End If
  189.             End If
  190.         End If
  191.     End If
  192.     
  193. End Sub
  194.  
  195. Sub command4_click ()
  196.     Dim TempString As String
  197.     fAddIndex.cTableName = TableName.Caption
  198.     fAddIndex.Show 1
  199.     TempString = TableName
  200.     If Not RefreshTableIndexes(Me, TempString) Then
  201.         MsgBox "Could Not Open Table:" + Chr$(13) + Error$, 64, "Data Manager"
  202.     End If
  203. End Sub
  204.  
  205. Sub Command5_Click ()
  206.     Dim x As Integer
  207.     Dim indx As String
  208.  
  209.     On Error Resume Next
  210.  
  211.     grid2.Col = 1
  212.     indx = grid2.Text
  213.  
  214.     If indx = "" Then
  215.         MsgBox "No Index Selected:  You must select a index before it can be deleted", 64, "Data Manager"
  216.     Else
  217.         x = MsgBox("Are You Sure You Want To Delete Index:  """ + indx + """?", 33, "Data Manager")
  218.         If x = 1 Then
  219.             'gDatabase.TableDefs.Refresh
  220.             'gDatabase.TableDefs(Me.TableName).Fields.Refresh
  221.             'If Err <> 0 Then
  222.                 'MsgBox "Error While Attempting To Refresh Table Info.  Database may have been altered by another source.  Displayed Information May be Incorrect:" + Chr$(13) + Error$, 64, "Data Manager"
  223.                 'Exit Sub
  224.             'End If
  225.  
  226.             gDatabase.TableDefs(Me.TableName).Indexes.Delete indx
  227.             If Err <> 0 Then
  228.                 MsgBox "Could Not Delete Index:  """ + indx + Chr$(13) + Error$, 64, "Data Manager"
  229.                 Exit Sub
  230.             Else
  231.                 If Not RefreshTableIndexes(Me, (Me.TableName)) Then
  232.                     MsgBox "Error While Attempting To Refresh Table Info.    Displayed Information May be Incorrect:" + Chr$(13) + Error$, 64, "Data Manager"
  233.                 End If
  234.             End If
  235.         End If
  236.     End If
  237.     
  238. End Sub
  239.  
  240. Sub Form_Load ()
  241.      Me.Tag = "Table"
  242.      top = 330
  243. End Sub
  244.  
  245. Sub Form_Resize ()
  246.  
  247.     If Me.WindowState = 0 Then
  248.         If Me.Width < (command3.Width + command3.left + 240) Then Me.Width = (command3.Width + command3.left + 240)
  249.         If Me.Height < (grid2.top + grid2.Height + 500) Then Me.Height = (grid2.top + grid2.Height + 500)
  250.     End